package com.gxa.meiye.admin.shop.controller;

import com.gxa.meiye.admin.shop.service.RegisterService;
import com.gxa.meiye.core.common.ResponseData;
import com.gxa.meiye.core.pojo.shopManagement.Shop;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author cc
 * @PackageName meiye
 * @Package com.gxa.meiye.admin.shop.controller
 * @Date 2022/7/20 21:33
 * @Version 1.0
 */
@RestController
@RequestMapping("shop")
public class AdminRegisterController {
    @Autowired
    private RegisterService registerService;

    @PostMapping("saveAll")
    @ApiOperation("前台调用向数据库存信息")
    public ResponseData saveAll(Shop shop){
        String pwd = shop.getPwd();
        String email = shop.getEmail();
        ResponseData rd = new ResponseData();
        SimpleHash simpleHash = new SimpleHash("MD5",pwd,email,1024);
        String MD5pwd = simpleHash.toString();
        shop.setPwd(MD5pwd);
        registerService.addAll(shop);
        return rd;
    }

    @PostMapping("checkEmail")
    @ApiOperation("前台调用查看账号是否已注册")
    public ResponseData checkEmail(String email){
        ResponseData rd = new ResponseData();
        /*email要校验的邮箱*/
        return registerService.checkEmail(email);
    }

}
